#include <QSettings>
#include "cssettingsinformation.h"

CSSettingsInformation::CSSettingsInformation()
{
}

void CSSettingsInformation::WriteDatabaseAddress(const QString &dbAddress)
{
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    myGroup->setValue("CSTools/dba",dbAddress);
    delete myGroup;
}

void CSSettingsInformation::WriteDatabaseUser(const QString &dbUser)
{
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    myGroup->setValue("CSTools/dbu",dbUser);
    delete myGroup;
}

void CSSettingsInformation::WriteDatabasePassword(const QString &dbPassword)
{
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    myGroup->setValue("CSTools/dbp",dbPassword);
    delete myGroup;
}

void CSSettingsInformation::WriteDatabasePort(const QString &dbPort)
{
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    myGroup->setValue("CSTools/dbport",dbPort);
    delete myGroup;
}

void CSSettingsInformation::WriteDatabaseName(const QString &dbName)
{
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    myGroup->setValue("CSTools/dbname",dbName);
    delete myGroup;
}

void CSSettingsInformation::WriteSingleFileStore(bool isSingleFile)
{
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "GUISettings");
    myGroup->setValue("CSTools/issinglefile", isSingleFile);
    delete myGroup;
}

void CSSettingsInformation::WriteSingleShowAgain(bool isShowAgain)
{
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "GUISettings");
    myGroup->setValue("CSTools/isShowAgain", isShowAgain);
    delete myGroup;
}

QString CSSettingsInformation::GetDataaseAddress()
{
    QString retval = "";
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    retval = myGroup->value("CSTools/dba").toString();
    delete myGroup;
    return retval;
}

QString CSSettingsInformation::GetDatabaseUser()
{
    QString retval = "";
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    retval = myGroup->value("CSTools/dbu").toString();
    delete myGroup;
    return retval;
}

QString CSSettingsInformation::GetDatabasePassword()
{
    QString retval = "";
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    retval = myGroup->value("CSTools/dbp").toString();
    delete myGroup;
    return retval;
}

QString CSSettingsInformation::GetDatabasePort()
{
    QString retval = "";
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    retval = myGroup->value("CSTools/dbport").toString();
    delete myGroup;
    return retval;
}

QString CSSettingsInformation::GetDatabaseName()
{
    QString retval = "";
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "Database");
    retval = myGroup->value("CSTools/dbname").toString();
    delete myGroup;
    return retval;
}

bool CSSettingsInformation::GetSingleFileStore()
{
    bool retval;
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "GUISettings");
    retval = myGroup->value("CSTools/issinglefile").toBool();
    delete myGroup;
    return retval;
}

bool CSSettingsInformation::GetSingleShowAgain()
{
    bool retval;
    QSettings * myGroup = new QSettings(QSettings::IniFormat, QSettings::UserScope, "CSTools", "GUISettings");
    retval = myGroup->value("CSTools/isShowAgain").toBool();
    delete myGroup;
    return retval;
}
